var listRepository = (function() {
    var getAll = function () {
        var list = null;
        $.ajax({
            url: 'api/list/get',
            async: false,
            dataType: 'json',
            success: function (data) {
                list = data;
                logger.success("List is loaded");
            }
        });

        return list;
    };
    
    var getClients = function () {
        var list = null;
        $.ajax({
            url: '../api/list/client',
            async: false,
            dataType: 'json',
            success: function (data) {
                list = data;
            }
        });

        return list;
    };
    
    var getRecentQuotes = function () {
        var list = null;
        $.ajax({
            url: '../api/list/getrecentquotes',
            async: false,
            dataType: 'json',
            success: function (data) {
                list = data;
            }
        });

        return list;
    };

    var save = function (data) {
        $.ajax({
            type: 'POST',
            url: 'api/list',
            data: data,
            dataType: 'json',
            contentType: 'application/json',
            success: function() {
                logger.success("List is saved");
            }
        });
    };

    return {
        getAll: getAll,
        getClients: getClients,
        getRecentQuotes: getRecentQuotes,
        save: save
    };
})();